from collections import deque
#import numpy as np
#import pandas as pd

q=deque(maxlen=5)
q.append(6)
q.append(7)
q.append(8)
q.append(9)

print len(q)
print dir(q)
for i in range(0,len(q)):
    print q[i]
print list(q)

def fingbigslope(nums):
    if nums == None:
        return
    nums = sorted(nums)
    # sorted by the 1th dimensional value
    slope = 0
    for i in range(len(nums)-1):
        axval = nums[i][0]
        ayval = nums[i][1]
        bxval = nums[i+1][0]
        byval = nums[i+1][1]
        slope_i = (byval - ayval) / float((bxval - axval))
        if abs(slope_i) > slope:
            slope = slope_i
    return slope


def newtons(f,df,x0,e):
    xn = float(x0)
    e_tmp = e+1
    loop = 1
    while e_tmp>e:
        print '########loop'+str(loop)
        k = df(xn)
        xm = f(xn)
        print 'xn='+str(xn)+',k='+str(k)+',y='+str(xm)
        q = xm/k
        xn = xn-q
        e_tmp = abs(0-f(xn))
        print 'new xn='+str(xn)+',e='+str(e_tmp)+',q='+str(q)
        loop=loop+1
    return xn

def f(x):
    return x**2+2*x

def df(x):
    return 2*x+2

#x = newtons(f,df,3,0.01)
#print 'the point you find is '+str(x)
#x = np.array([2,3,4,6])
#xx = pd.DataFrame({"k": x})
#yy = pd.Series([22,33,44,66])
#dir(pd)
#res = pd.ols(y=yy, x=xx)
